package niit.game;

import java.util.List;

import android.graphics.Bitmap;
import android.graphics.Canvas;

public class Temp {
	private float x;
    private float y;
    private Bitmap bmp;
    private int life = 5;
    private List<Temp> temps;

    public Temp(List<Temp> temps, GameView gameView, float x,
                 float y, Bitmap bmp) {
          this.x = Math.min(Math.max(x , 0),
                        gameView.getWidth() - bmp.getWidth());
          this.y = Math.min(Math.max(y , 0),
                        gameView.getHeight() - bmp.getHeight());
          this.bmp = bmp;
          this.temps = temps;
    }

    public void onDraw(Canvas canvas) {
          update();
          canvas.drawBitmap(bmp, x, y, null);
    }

    private void update() {
          if (--life < 1) {
                 temps.remove(this);
          }
    }
}
